#define combo(x,num,placeholder)
	  <div class="input-group">
           <input type="text" class="form-control" id="combo_#(x.index??)" #(x.required??) placeholder="#(placeholder??)">	
				#setLocal(val = x.value??'')
				#setLocal(token = "token_")
				#if (val != "")
				 	token = ""
				#end
           <input type="hidden" id="_#(x.index??)" name="#(token)#(table??x.table).#(x.index??)"/>
           <input type="hidden" id="_#(x.tail??)" name="#(table??x.table).#(x.tail??)"/>
           <div class="input-group-btn">
                <button type="button" id="btn_#(x.index??)" class="btn btn-sx btn-white">
					<span>x</span> 
				</button>
                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                </ul>
           </div>
            <!-- /btn-group -->
        </div>
        <script src="/static/assets/js/bootstrap-suggest.js" type="text/javascript" ></script>
		<script type="text/javascript">
		    var _#(x.index??)_effectiveFields = [];
	        var _#(x.index??)_effectiveFieldsAlias = {};
	        var _#(x.index??)_keyField ="text";
			$(function(){
				 $("#btn_#(x.index??)").bind("click",function(){
					    $("#_#(x.index??)").val("");
					    $("#combo_#(x.index??)").val("");
				 });
				 $("#combo_#(x.index??)").bind("focus",function(){
						var _name = $("#_#(x.index??)").attr("name").replace("token_", "");
						$("#_#(x.index??)").attr("name", _name);
						$("#form_token").val(1);
				 });
				 #if(x.combofield!=null)
			    		#for(k : x.combofield)
			    			#if(for.first)
			    				_#(x.index??)_keyField = "#(k.key)";
			    			#end
			    			_#(x.index??)_effectiveFields.push("#(k.key)");
			    		    _#(x.index??)_effectiveFieldsAlias["#(k.key)"] = "#(k.value)";
			    		#end
				 #end
				 
				 _#(x.index??)_initcombo();
			});
			function  _#(x.index??)_initcombo(){
				 $.post("/cache/getCombo", {code:"#(num??)"}, function (data) {
						if(data.code===0){
						    $("#combo_#(x.index??)").bsSuggest({
						    	idField: "id",       
						    	keyField: _#(x.index??)_keyField,       
						        data: {
						            'value':data.data
						        },
						        effectiveFields:_#(x.index??)_effectiveFields,
						        effectiveFieldsAlias:_#(x.index??)_effectiveFieldsAlias,
						    }).on('onSetSelectValue', function (e, keyword) {
						        $("#_#(x.index??)").val(keyword.id);
						        $("#_#(x.tail??)").val(keyword.key);
						    });
						    var comboModle=#(model??"null");
						    if(comboModle==null){return;};
						    var _comboid=comboModle["#(x.index??)"];
						    for(var i=0;i<data.data.length;i++){
						    	if(data.data[i].id==_comboid){
								    $("#combo_#(x.index??)").val(data.data[i].text);
						    		return;
						    	}
						    }
						}
			     }, "json");
			}
		</script>
		
#end